﻿
using System;
using System.Collections.Generic;
using System.Text;
using OF.Utility.Logging;

namespace OF.Utility.Logging
{
    /// <summary>
    /// 业务操作日志
    /// </summary>
    [Serializable]
    public class BusinessLog
    {
        /// <summary>
        /// 系统ID
        /// </summary>
        public int PlatformID { get; set; }
        /// <summary>
        /// 模块名称
        /// </summary>
        public string ModuleName
        {
            get;
            set;
        }
        /// <summary>
        /// 模块内方法名称
        /// </summary>
        public string MethodName
        {
            get;
            set;
        }
        /// <summary>
        /// 操作对象ID
        /// </summary>
        public string TargetID
        {
            get;
            set;
        }
        /// <summary>
        /// 操作内容
        /// </summary>
        public String OpContent
        {
            get;
            set;
        }
        /// <summary>
        /// 更新数据前旧值
        /// </summary>
        public string OldDataValue { get; set; }
        /// <summary>
        /// 更新数据前旧值
        /// </summary>
        public string NewDataValue { get; set; }

        /// <summary>
        /// 操作用户ID
        /// </summary>
        public long OpUserID { get; set; }
        /// <summary>
        /// 操作人员名称
        /// </summary>
        public string OpUserName { get; set; }
        /// <summary>
        /// 服务器名称
        /// </summary>
        public string ServerName { get; set; }
        /// <summary>
        /// 客户端IP地址
        /// </summary>
        public string ClientIP { get; set; }

        /// <summary>
        /// 请求页面地址
        /// </summary>
        public string PageUrl { get; set; }

        /// <summary>
        /// 数据所属机构
        /// </summary>
        public int OrganizationID
        {
            get;
            set;
        }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateDateTime { get; set; }
        public override string ToString()
        {
            StringBuilder writer = new StringBuilder();
            StringBuilder sb = new StringBuilder("操作详情：");
            writer.AppendLine();
            writer.AppendFormat("模块名称：{0}\r\n", this.ModuleName);
            writer.AppendFormat("方法名称：{0}\r\n", this.MethodName);
            writer.AppendFormat("操作对象ID：{0}\r\n", this.TargetID);
            writer.AppendFormat("数据所属机构：{0}\r\n", this.OrganizationID);
            writer.AppendFormat("操作内容：{0}\r\n", this.OpContent);
            writer.AppendFormat("当前用户：{0}\r\n", this.OpUserName);
            writer.AppendFormat("Web服务器地址：{0}\r\n", this.ServerName);
            writer.AppendFormat("客户端IP：{0}\r\n", this.ClientIP);
            writer.AppendFormat("用户请求URL：{0}\r\n", this.PageUrl);
            return writer.ToString();
        }
    }
}